<template>
  <div>
    <el-container>
      <el-header>
        <HeaderBar />
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-location" />
                <span>我的订单</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="1-1" @click="getAllTable">全部</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group>
                <el-menu-item index="1-2" @click="getPendingPay">待付款</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group>
                <el-menu-item index="1-3" @click="getCompleted">已完成</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-menu-item index="2">
              <i class="el-icon-star-on" />
              <span slot="title">我的收藏</span>
            </el-menu-item>
            <el-menu-item index="3" @click="tableFlag = false">
              <i class="el-icon-user-solid" />
              <span slot="title">个人信息</span>
            </el-menu-item>
          </el-menu></el-aside>
        <el-main>
          <div style="margin-left: 50px">
            <OrderDisplay v-show="tableFlag" :order-array="myTableData" />
            <PersonalInfo v-show="!tableFlag" />
          </div>
        </el-main>
      </el-container>
    </el-container>
    <SideBar />
    <EndBar style="margin-top:200px" />
  </div>
</template>

<script>
import OrderDisplay from '../../components/order/OrderDisplay'
import PersonalInfo from '../../components/PersonalInfo'
import HeaderBar from '../../components/bars/HeaderBar'
import EndBar from '../../components/bars/EndBar'
import SideBar from '../../components/bars/SideBar'
export default {
  components: {
    OrderDisplay,
    PersonalInfo,
    HeaderBar,
    EndBar,
    SideBar
  },
  data() {
    return {
      activeIndex: '1',
      tableFlag: true,
      OriginTableData: [
        {
          id: 1,
          date: '2020-05-02',
          name: '测试用户1',
          address: '浙江理工大学信息学院10-301',
          price: '100.05',
          status: '未支付'
        },
        {
          id: 2,
          date: '2020-05-04',
          name: '测试用户2',
          address: '浙江理工大学信息学院10-302',
          price: '110.05',
          status: '支付宝支付'
        },
        {
          id: 3,
          date: '2020-05-01',
          name: '测试用户2',
          address: '浙江理工大学信息学院10-303',
          price: '80.08',
          status: '微信支付'
        },
        {
          id: 4,
          date: '2020-05-03',
          name: '测试用户1',
          address: '浙江理工大学信息学院10-304',
          price: '90.00',
          status: '银行卡支付'
        }
      ],

      myTableData: [

      ]
    }
  },
  created() {
    this.myTableData = this.OriginTableData
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath)
    },
    getAllTable() {
      this.tableFlag = true
      this.myTableData = this.OriginTableData
    },
    getPendingPay() {
      this.tableFlag = true
      this.myTableData = this.OriginTableData.filter(item => item.status === '未支付')
    },
    getCompleted() {
      this.tableFlag = true
      this.myTableData = this.OriginTableData.filter(item => item.status !== '未支付')
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    }
  }
}
</script>

<style>
@import "../../assets/css/origincss/reset.css";
@import "../../assets/css/origincss/index.css";
@import "../../assets/css/origincss/common.css";
@import "../../assets/css/origincss/login.css";
</style>
